﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using Peak.Core;

namespace Peak.Data.NHibernateMaps
{
  public class SprintMap : IAutoMappingOverride<Sprint>
  {
    public void Override(AutoMapping<Sprint> mapping)
    {
      mapping.Id(x => x.Id, "id").UnsavedValue(0).GeneratedBy.Identity();
      mapping.Map(x => x.Name).Not.Nullable();
      mapping.Map(x => x.Description);      
      mapping.Map(x => x.StartDate);
      mapping.Map(x => x.EndDate);
      mapping.Map(x => x.Created).Not.Nullable();
      mapping.Map(x => x.CreatedBy);
      mapping.Map(x => x.CurrentEffort);
      mapping.Map(x => x.EstimatedVelocity);
      mapping.Map(x => x.RealVelocity);
      mapping.Map(x => x.InitialEffort);
      mapping.Map(x => x.EstimatedEffort);
      mapping.Map(x => x.RemainingEffort);      
      mapping.Map(x => x.Status).CustomType(typeof(SprintStatus)).Not.Nullable().Default(((int)SprintStatus.Planning).ToString()); ;
      mapping.HasMany(x => x.SprintStories);
      mapping.HasMany(x => x.Burndown).Cascade.All();
      mapping.References(x => x.Project).Cascade.All();
    }
  }
}